<!DOCTYPE html>
<html>
<head>
    <title>清除Token</title>
    <meta charset="UTF-8">
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .container {
            background: white;
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            text-align: center;
            max-width: 500px;
        }
        h1 {
            color: #333;
            margin-bottom: 20px;
        }
        .info {
            background: #f0f9ff;
            border-left: 4px solid #0ea5e9;
            padding: 15px;
            margin: 20px 0;
            text-align: left;
        }
        .success {
            background: #f0fdf4;
            border-left: 4px solid #22c55e;
            padding: 15px;
            margin: 20px 0;
            display: none;
        }
        button {
            background: #667eea;
            color: white;
            border: none;
            padding: 12px 30px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            margin: 10px;
        }
        button:hover {
            background: #5568d3;
        }
        .danger {
            background: #ef4444;
        }
        .danger:hover {
            background: #dc2626;
        }
        pre {
            background: #f5f5f5;
            padding: 10px;
            border-radius: 5px;
            text-align: left;
            overflow-x: auto;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🔧 清除Token工具</h1>
        
        <div class="info">
            <h3>⚠️ 当前问题</h3>
            <p>您的登录Token已过期或无效，导致无法访问系统功能。</p>
            <p><strong>错误信息：</strong></p>
            <pre>JWT signature does not match locally computed signature</pre>
        </div>

        <div id="tokenInfo" style="margin: 20px 0;">
            <h3>📋 当前Token信息</h3>
            <pre id="currentToken" style="word-break: break-all; white-space: pre-wrap;"></pre>
        </div>

        <button onclick="clearToken()" class="danger">清除Token</button>
        <button onclick="goToLogin()">前往登录</button>

        <div id="success" class="success">
            <h3>✅ Token已清除</h3>
            <p>请点击"前往登录"按钮重新登录系统。</p>
        </div>
    </div>

    <script>
        // 显示当前Token
        function showCurrentToken() {
            const token = localStorage.getItem('token');
            const tokenElement = document.getElementById('currentToken');
            
            if (token) {
                tokenElement.textContent = `Token: ${token.substring(0, 50)}...\n长度: ${token.length} 字符`;
            } else {
                tokenElement.textContent = '未找到Token';
            }
        }

        // 清除Token
        function clearToken() {
            // 清除localStorage中的所有数据
            localStorage.clear();
            
            // 清除sessionStorage中的所有数据
            sessionStorage.clear();
            
            // 显示成功消息
            document.getElementById('success').style.display = 'block';
            document.getElementById('tokenInfo').style.display = 'none';
            
            console.log('✅ Token已清除');
            console.log('✅ localStorage已清空');
            console.log('✅ sessionStorage已清空');
        }

        // 前往登录页面
        function goToLogin() {
            window.location.href = '/';
        }

        // 页面加载时显示当前Token
        showCurrentToken();
    </script>
</body>
</html>

